package cn.kongwg.demo05;

import sun.net.www.http.HttpClient;

import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.regex.Pattern;

/**
 * @author kongwg
 * @create 2021-06-07 17:47
 */
public class StrReverse {
    public static void main(String[] args) throws UnsupportedEncodingException {
//        String s = "helloworld";
//        StringBuilder stringBuilder = new StringBuilder(s);
//        StringBuilder reverse = stringBuilder.reverse();
//        System.out.println("reverse = " + reverse);
//        String str = new String("hello123".getBytes("GB2312"), "ISO-8859-1");
//        System.out.println(str);
//        LocalDateTime localDateTime = LocalDateTime.now().plusDays(-1);
//        System.out.println(localDateTime);
//        String str1 = "123456";
//        String str2 = Pattern.compile("\\d").matcher(str1).replaceAll("0");
//        System.out.println("str = " + str2);
//        String temp[] = {"1", "2", "3"};
//        System.out.println("temp = " + Arrays.toString(temp));
        String s = "kongwg";
        String reverse = reverse(s);
        System.out.println("reverse = " + reverse);

    }

    public static String reverse(String str) {
        StringBuilder stringBuilder = new StringBuilder();
        char[] chars = str.toCharArray();
        for (int i = chars.length-1; i >= 0; i--) {

            stringBuilder.append(chars[i]);


        }
        return stringBuilder.toString();

    }
}
